package org.example.virtualsensors.entity.model;


import java.util.HashMap;
import java.util.Map;

/**
 * 监测量的状态分为：正常、预警、告警、未知
 * @author jiangym
 */
public enum EmsQuantityStatus {

    UNKNOWN(0), NORMAL(1), PERALARM(2), ALARM(3);

    public static final Map<EmsQuantityStatus, String> STATUS_DESC = new HashMap<EmsQuantityStatus, String>(4);

    static {
        STATUS_DESC.put(UNKNOWN, "rtcommon.status.1");
        STATUS_DESC.put(NORMAL, "rtcommon.status.2");
        STATUS_DESC.put(PERALARM, "rtcommon.status.3");
        STATUS_DESC.put(ALARM, "rtcommon.status.4");
    }

    private final int status;

    private EmsQuantityStatus(final int status) {
        this.status = status;
    }

    public int status() {
        return this.status;
    }

    /**
     * 根据枚举实例获取对应的实例文字描述
     *
     * @return
     */
    public String stringValue(EmsQuantityStatus status) {
        return STATUS_DESC.get(status);
    }

    /**
     * 根据状态值，获取对应的枚举实例
     *
     * @return
     */
    public static EmsQuantityStatus valueOf(int _status) {
        for (EmsQuantityStatus status : values()) {
            if (status.status() == _status) {
                return status;
            }
        }
        return null;
    }

    /**
     * 根据Status实例获取该Status的描述
     *
     * @param status
     * @return
     */
//    public static String getStatusDesc(EmsQuantityStatus status) {
//        String value = STATUS_DESC.get(status);
//        return I18nUtils.getI18nByKeyAppendEmpty(value);
//    }

}
